/*
 * Copyright (c) 2014 pkzd/1.0, 颜文泽(robin)
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *     1 Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     2 Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef MC_FS_H
#define MC_FS_H

#include        <buf.h>
#include        <ide.h>
#include	<file.h>
#include        <time.h>
#include	<proc.h>
#include	<stat.h>
#include	<errno.h>
#include        <param.h>
#include        <direct.h>
#include	<mount.h>
#include        <string.h>
#include        <filsys.h>

extern struct inode *rootp;

ino_t	ialloc(dev_t dev);
ino_t	findfile(struct inode *ip, char *name);
void	iput(struct inode *ip);
void	free(dev_t dev, uint bno);
void	ifree(dev_t dev, ino_t ino);
uint	alloc(dev_t dev);
uint	balloc(dev_t dev);
uint	bmap(struct inode *ip, uint bn);
uint	ioadd(struct inode *ip, void *buf, uint cnt);
int	itrunc(struct inode *ip);
int	iupdat(struct inode *ip);
int	iwrite(struct inode *ip);
int	isempty(struct inode *ip);
int	bbread(uint bn, void *buf);
int	bbwrite(uint bn, void *buf);
int	access0(struct inode *ip, mode_t mode);
int	iread(dev_t dev, ino_t ino, struct inode *ip);
int	wddir(struct inode *ip, struct direct *dp, int flag);
int	log_read(uint bn, void *buf, struct inode *ip, uint cnt);
int	log_write(uint bn, void *buf, struct inode *ip, uint cnt);
struct inode *iget(dev_t dev, ino_t ino);
struct inode *namei(char *pathname, char flag, ino_t ino1);
char	*have_path(char *path, char *buf);

int	dup(int fd);
int	close(int fd);
int	read(int fd, char *buf, size_t cnt);
int	write(int fd, const char *buf, size_t cnt);
int	creat(const char *pathname, mode_t mode);
int	access(const char *pathname, mode_t mode);
int	unlink(const char *path);
int	link(const char *oldpath, const char *newpath);
int	open(const char *pathname, int flags, mode_t mode);
int	mknod(const char *pathname, mode_t mode, dev_t dev);
off_t	lseek(int fd, off_t offset, int whence);
int	rmdir(const char *pathname);
int	mkdir(const char *pathname, mode_t mode);
int	chdir(char *pathname);
int	fstat(int fd, struct stat *stbuf);
int	stat(const char *pathname, struct stat *stbuf);

#endif
